package cn.itsource.basic.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class MailService {

    @Autowired
    private JavaMailSender javaMailSender;

    /**
     * 做一个配置,有一个表专门做配置表
     *
     * 功能:页面做配置
     * @param subject
     * @param text
     * @param to
     */
    public void sendMail(String subject,String text,String to){
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        //设置发送人
        mailMessage.setFrom(Constant.MAIL_SENDER);
        //邮件主题
        mailMessage.setSubject(subject);
        //邮件内容
        mailMessage.setText(text);
        //收件人
        mailMessage.setTo(to);

        javaMailSender.send(mailMessage);
    }


}
